package cn.keyvalue.ccf.common.util;

import org.apache.commons.lang3.StringUtils;

public class ShopUtils {

	/**
	 * 根据url返回shopid，不断添加中
	 * @param url
	 * @return
	 */
	public static int getShopID( String url )
	{
		Integer[] shopids = new Integer[]{
				ShopConst.SHOPID_360BUY,
				ShopConst.SHOPID_51BUY,
				ShopConst.SHOPID_COO8,
				ShopConst.SHOPID_GOME,
				ShopConst.SHOPID_YIHAODIAN,
				ShopConst.SHOPID_SUNING,
				ShopConst.SHOPID_NEWEGG,
				ShopConst.SHOPID_TMALL
		};
		
		String[] keywords = new String[]{
				"360buy.com;jd.com",
				"51buy.com",
				"coo8.com",
				"gome.com.cn",
				"yihaodian.com;1mall.com",
				"suning.com",				
				"newegg.com",
				"tmall.com"
		};
		
		for( int i = 0; i < keywords.length; i++ )
		{
			String keyword = keywords[i];
			String[] sArray = keyword.split(";");
			
			for( String s:sArray )
			{
				if( StringUtils.contains(url, s) )
				{
					return shopids[i];
				}
			}
		}
		
		return -1;
	}
	
	
	
	public static void main( String[] args )
	{
		String u = "jd.cotmall.com";
		
		System.out.println( getShopID(u) );
	}
}
